package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.Salary;
import cn.wolfcode.crm.qo.EmployeeQueryObject;
import cn.wolfcode.crm.qo.PageResult;
import cn.wolfcode.crm.qo.SalaryQueryObject;
import cn.wolfcode.crm.qo.SaleorderQueryObject;
import cn.wolfcode.crm.service.ISalaryService;
import cn.wolfcode.crm.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@RequestMapping("salary")
@Controller
public class SalaryController {

    @Autowired
    private ISalaryService salaryService;

    @RequestMapping("view")
    public String view() {
        return "/salary/salary";
    }

    @RequestMapping("query")
    @ResponseBody
    public PageResult query(SalaryQueryObject qo) {
        return salaryService.query(qo);
    }
    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public JSONResult saveOrUpdate(Salary salary)
    {
        try
        {
            if (salary.getId() != null)
                salaryService.updateById(salary);
            else
                salaryService.insert(salary);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            return JSONResult.mark("保存失败!");
        }
        return JSONResult.success("保存成功!");
    }
    public Salary selectByJopNumber(String jopNumber)
    {
        return salaryService.selectByJopNumber(jopNumber);
    }
}
